package javabase.collection.list.performance;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayListCapability {

	public static void main(String[] args) {
		String [] strArray = new String[200000];
		Arrays.fill(strArray, "test");
		
		List<String> list = new ArrayList<String>(Arrays.asList(strArray));
		long startTime = System.currentTimeMillis();
		for (int i = 0; i < 10000; i ++) {
			list.add(0, "world");
		}
		System.out.println(list.size());
		long endTime = System.currentTimeMillis();
		//10W:9610 2W:2823
		System.out.println("在一个已有20W个元素的ArrayList前面插入10W需耗时：" + (endTime - startTime));
	}

}
